#!/bin/sh

cd /etc/systemd/system/multi-user.target.wants/;
list=`ls netspeeder-* | cut -b 12-`;
index=0; 
for i in $${list}; do
    index=$$((index+1));
    echo $${index}.$$i;
done;
echo -n "uninstall: "; read choose;
server_name=`echo $${list} | awk '{ print $$'$${choose}' }'`;
while :; do
    echo -n "will remove netspeeder-$${server_name}, is that ok? [yes/no] "; read ok; [ "x$${ok}" = xyes ] && break; [ "x$${ok}" = xno ] && exit 1;
done;
echo systemctl stop netspeeder-$${server_name}; systemctl stop netspeeder-$${server_name};
echo systemctl disable netspeeder-$${server_name}; systemctl disable netspeeder-$${server_name};
echo rm -f /lib/systemd/system/netspeeder-$${server_name}.service; rm -f /lib/systemd/system/netspeeder-$${server_name}.service;
echo "finish";
